package com.psp.bu.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.northend.util.AppTextUtil;
import com.psp.bu.controller.res.bean.RApplySPListBean;
import com.psp.bu.controller.res.bean.RJoinedSPBean;
import com.psp.bu.controller.res.bean.RSPCommentListBean;
import com.psp.bu.controller.res.bean.RSPDetailBean;
import com.psp.bu.controller.res.bean.RSPOrderListBean;
import com.psp.bu.service.SPService;
import com.psp.bu.service.exception.ServiceException;

@Service("spServiceImpl")
public class SPServiceImpl implements SPService {

	@Override
	public PageResult<RJoinedSPBean> getJoined(int page, int pageSize, String name, String uid) {
		PageResult<RJoinedSPBean> result = new PageResult<>();

		List<RJoinedSPBean> list = new ArrayList<>();
		for (int i = 0; i < 20; i++) {
			RJoinedSPBean bean = new RJoinedSPBean();
			bean.setSpid(AppTextUtil.getPrimaryKey());
			bean.setName("硬创云加信息技术有限公司");
			bean.setLogo("http://pic.58pic.com/58pic/14/00/69/66858PICNfJ_1024.jpg");
			bean.setContact("李四");
			bean.setPhone("010-6255-3654");
			bean.setField("工商服务");
			bean.setSecField("工商财税");
			bean.setOrderNum(new Random().nextInt(10));
			bean.setArt(new Random().nextInt(60));
			bean.setAct(new Random().nextInt(10));
			bean.setScore(new Random().nextInt(5));
			bean.setJoinDate(System.currentTimeMillis());
			list.add(bean);
		}
		result.setCount(40);
		result.setData(list);
		return result;
	}

	@Override
	public PageResult<RApplySPListBean> getApply(int page, int pageSize, String name, String uid) {
		PageResult<RApplySPListBean> result = new PageResult<>();

		List<RApplySPListBean> list = new ArrayList<>();
		for (int i = 0; i < 20; i++) {
			RApplySPListBean bean = new RApplySPListBean();
			bean.setSpid(AppTextUtil.getPrimaryKey());
			bean.setName("硬创云加信息技术有限公司");
			bean.setLogo("http://pic.58pic.com/58pic/14/00/69/66858PICNfJ_1024.jpg");
			bean.setContact("李四");
			bean.setPhone("010-6255-3654");
			bean.setField("工商服务");
			bean.setSecField("工商财税");
			bean.setBrief("公司简介 ，公司简介");
			list.add(bean);
		}
		result.setCount(40);
		result.setData(list);
		return result;
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean agreeJoin(String uid, String spid) throws ServiceException {
		boolean flag = false;

		return true;
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean disagreeJoin(String uid, String spid) throws ServiceException {
		boolean flag = false;

		return true;
	}

	@Override
	public PageResult<RSPCommentListBean> getComments(int page, int pageSize, String uid, String spid) {
		PageResult<RSPCommentListBean> result = new PageResult<>();

		List<RSPCommentListBean> list = new ArrayList<>();
		for (int i = 0; i < 20; i++) {
			RSPCommentListBean bean = new RSPCommentListBean();
			bean.setContent("评论内容");
			list.add(bean);
		}
		result.setCount(40);
		result.setData(list);
		return result;
	}

	@Override
	public PageResult<RSPOrderListBean> getOrders(int page, int pageSize, String uid, String spid) {
		PageResult<RSPOrderListBean> result = new PageResult<>();

		List<RSPOrderListBean> list = new ArrayList<>();
		for (int i = 0; i < 20; i++) {
			RSPOrderListBean bean = new RSPOrderListBean();
			bean.setTitle("订单");
			list.add(bean);
		}
		result.setCount(40);
		result.setData(list);
		return result;
	}

	@Override
	public RSPDetailBean getDetail(String spid) {
		RSPDetailBean bean = new RSPDetailBean();
		bean.setSpid(AppTextUtil.getPrimaryKey());
		bean.setName("硬创云加信息技术有限公司");
		bean.setLogo("http://pic.58pic.com/58pic/14/00/69/66858PICNfJ_1024.jpg");
		bean.setContact("李四");
		bean.setPhone("010-6255-3654");
		bean.setField("工商服务");
		bean.setSecField("工商财税");
		bean.setOrderNum(new Random().nextInt(10));
		bean.setArt(new Random().nextInt(60));
		bean.setAct(new Random().nextInt(10));
		bean.setScore(new Random().nextInt(5));
		bean.setJoinDate(System.currentTimeMillis());
		return bean;
	}

}
